package com.repair.admin.category.controller;

import com.repair.admin.category.service.AdminCategoryService;
import com.repair.api.category.request.param.ServiceCategoryDeleteParam;
import com.repair.api.category.request.param.ServiceCategoryGetParam;
import com.repair.api.category.request.param.ServiceCategorySaveParam;
import com.repair.api.category.response.data.CategoryInfo;
import com.repair.base.result.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("categoryAdmin")
public class AdminCategoryController {
    @Autowired
    private AdminCategoryService adminCategoryService;
    @GetMapping("getAllPrimaryCategories")
    public JsonResult<List<CategoryInfo>> getAllPrimaryCategory(ServiceCategoryGetParam serviceCategoryGetParam){
        List<CategoryInfo> allCategories = adminCategoryService.getAllCategories(serviceCategoryGetParam);
        return JsonResult.ok(allCategories);
    }
    @PostMapping("/save")
    public JsonResult<String> save(ServiceCategorySaveParam serviceCategorySaveParam) {
        adminCategoryService.save(serviceCategorySaveParam);
        return JsonResult.ok("保存成功");
    }
    @PostMapping("/delete")
    public JsonResult<String> delete(ServiceCategoryDeleteParam serviceCategoryDeleteParam) {
        adminCategoryService.delete(serviceCategoryDeleteParam);
        return JsonResult.ok("删除成功");
    }
}
